import java.util.*;

public class Text {
    public static void main4(String[] args) {
        int[] array = {1,5,6,9,7,1,5,9};
        Map<Integer,Integer> map = new HashMap<>();
        for (int x: array) {
            if (!map.containsKey(x)) {
                map.put(x,1);
            } else {
                int val = map.get(x);
                map.put(x,val + 1);
            }
        }
        for (Map.Entry<Integer,Integer> entry: map.entrySet()) {
            if (entry.getValue() > 1) {
                System.out.println("key: " + entry.getKey() + " value: " + entry.getValue());
            }
        }
    }
    //十个数据去重
    public static void main3(String[] args) {
        int[] array = {1,5,6,9,7,1,5,9};
        Set<Integer> set = new HashSet<>();
        for (int x: array) {
            if (!set.contains(x)) {
                set.add(x);
            } else {
                System.out.println(x);
                return ;
            }
        }

    }
    public static void main(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(5,55);
        hashBuck.put(8,88);
        hashBuck.put(3,33);
        hashBuck.put(14,144);
        hashBuck.put(6,66);
        hashBuck.put(7,77);
        Integer val = hashBuck.get(5);
        System.out.println(val);
    }
    public static void main1(String[] args) {
        Map<String,Integer> treeMap = new TreeMap<>();
       treeMap.put("hello",8);
       treeMap.put("abc",4);
       treeMap.put("the",5);
        System.out.println(treeMap);
        Integer s = treeMap.get("hello");//返回key对应的value值
        Integer b =treeMap.get("abc");
        System.out.println(s);
        System.out.println(b);
        System.out.println(treeMap.getOrDefault("abcd",80));
        Set<String> keySet = treeMap.keySet();
        System.out.println(keySet);
        System.out.println("============");
        Set<Map.Entry<String,Integer>> Set =  treeMap.entrySet();
        for (Map.Entry<String,Integer> entry : Set) {
            System.out.println("key: " + entry.getKey()+" value: " + entry.getValue());
        }
    }
}
